package LeetCode._02_数组;

public class _300_最长递增子序列 {
    public int lengthOfLIS(int[] nums) {
        if(nums == null || nums.length == 0) return 0;
        int[] dp = new int[nums.length]; //状态方程：dp(i):以nums[i]结尾的最长递增子序列的和
        int max = dp[0] = 1;//初始状态
        for(int i=1;i<nums.length;i++){
            dp[i] = 1;
            for(int j=0;j<i;j++){
                if(nums[i]<=nums[j]) continue;
                dp[i] = Math.max(dp[i],dp[j] + 1);
            }
            max = Math.max(dp[i],max);
        }
        return max;
    }
}
